package com.xywang.dao.user;

import com.xywang.pojo.User;
import org.mybatis.spring.SqlSessionTemplate;

import java.util.List;

public class UserDaoImpl implements UserDao{
    private SqlSessionTemplate sqlSessionTemplate;
    public void setSqlSessionTemplate(SqlSessionTemplate sqlSessionTemplate) {
        this.sqlSessionTemplate = sqlSessionTemplate;
    }
    @Override
    public User getLoginUser(String userCode) {
        return sqlSessionTemplate.getMapper(UserDao.class).getLoginUser(userCode);
    }

    @Override
    public int updatePwd(int id, String password) {
        return sqlSessionTemplate.getMapper(UserDao.class).updatePwd(id,password);
    }

    @Override
    public int getUserCount(String username, int userRole) {
        return sqlSessionTemplate.getMapper(UserDao.class).getUserCount(username,userRole);
    }

    @Override
    public List<User> getUserList(String userName, int userRole, int currentPageNo, int pageSize) {
        return sqlSessionTemplate.getMapper(UserDao.class).getUserList(userName,userRole,currentPageNo,pageSize);
    }

    @Override
    public int addUserDao(User user) {
        return sqlSessionTemplate.getMapper(UserDao.class).addUserDao(user);
    }

    @Override
    public int deleteUser(int id) {
        return sqlSessionTemplate.getMapper(UserDao.class).deleteUser(id);
    }

    @Override
    public User getUserById(int id) {
        return sqlSessionTemplate.getMapper(UserDao.class).getUserById(id);
    }

    @Override
    public int updateUser(User user) {
        return sqlSessionTemplate.getMapper(UserDao.class).updateUser(user);
    }
}
